package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"
)

// Metric holds the schema definition for the Metric entity.
type Metric struct {
	ent.Schema
}

// Fields of the Metric.
func (Metric) Fields() []ent.Field {
	return []ent.Field{
		field.String("name").Unique(),
	}
}

// Edges of the Metric.
func (Metric) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("rule_from", Rule.Type).Ref("in_metric"),
		edge.From("aggregated_by", Setting.Type).Ref("with_metric"),

		edge.From("has_logs", AlarmLog.Type).Ref("sent_for_metric"),
	}
}
